package wpspider.client.common;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * WPSpiderProperties class.
 */
public class WPSpiderProperties {
    /** Properties file. */
    public static final String PROPERTIES_FILE = "wpspider.properties";
    /** Singleton instance. */
    private static WPSpiderProperties _instance = null;
    /** Properties object. */
    private Properties _prop;

    /**
     * Constructor. (private)
     * @throws IOException
     */
    private WPSpiderProperties() throws IOException {
        _prop = new Properties();
        _prop.load(new FileInputStream(PROPERTIES_FILE));
    }

    /**
     * Gets Singleton instance.
     * @return Singleton instance.
     * @throws IOException
     */
    public static WPSpiderProperties getInstance() throws IOException {
        if (_instance == null) {
            _instance = new WPSpiderProperties();
        }
        return _instance;
    }

    /**
     * Gets property value.
     * @param key Property key.
     * @return Property value.
     */
    public String getProperty(final String key) {
        return _prop.getProperty(key);
    }
}
